package com.hjm.project.merchantModelDetail.domain;

import lombok.Data;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Min;
import java.math.BigDecimal;
import java.util.List;

/**
 * 商户费率转换Vo
 * @author surplus
 * @date 2022-06-07
 */
@Data
public class MerchantModelDetailVo {

    private String modelNo;

    /** 银行卡收单 贷记卡 **/
    @DecimalMin(value = "0.53",message = "银行卡贷记卡D0费率最低0.53")
    private BigDecimal yinhangkaDaijikaD0;      //银行卡贷记卡D0费率
    private Integer    yinhangkaDaijikaD0Fj;    //银行卡贷记卡D0附加

    /** 银行卡收单 借记卡 D0 **/
    @DecimalMin(value = "0.53",message = "银行卡借记卡D0费率最低0.53")
    private BigDecimal yinhangkaJiejikaD0;      //银行卡借记卡D0费率
    @Min(value = 20,message = "银行卡借记卡D0封顶最低20")
    private Integer    yinhangkaJiejikaD0Fd;    //银行卡借记卡D0封顶
    private Integer    yinhangkaJiejikaD0Fj;    //银行卡借记卡D0附加

    /** 云闪付 贷记卡 **/
    @DecimalMin(value = "0.30",message = "云闪付贷记卡D0费率最低0.30")
    private BigDecimal yunshanFuDaijikaD0;      //云闪付贷记卡D0费率
    private Integer    yunshanFuDaijikaD0Fj;    //云闪付贷记卡D0附加

    /** 云闪付 借记卡 **/
    @DecimalMin(value = "0.30",message = "云闪付借记卡D0费率最低0.30")
    private BigDecimal yunshanFuJiejikaD0;      //云闪付借记卡D0费率
    private Integer    yunshanFuJiejikaD0Fj;    //云闪付借记卡D0附加

    /** 银联二维码 贷记卡 **/
    @DecimalMin(value = "0.30",message = "银联二维码贷记卡D0费率最低0.30")
    private BigDecimal qrDaijikaD0;      //银联二维码贷记卡D0费率
    private Integer    qrDaijikaD0Fj;    //银联二维码贷记卡D0附加

    /** 银联二维码 借记卡 **/
    @DecimalMin(value = "0.30",message = "银联二维码借记卡D0费率最低0.30")
    private BigDecimal qrJiejikaD0;      //银联二维码借记卡D0费率
    private Integer    qrJiejikaD0Fj;    //银联二维码借记卡D0附加
    private Integer    qrJiejikaD0Fd;    //银联二维码借记卡D0封顶

    /** 微信 借记卡 **/
    @DecimalMin(value = "0.30",message = "微信借记卡D0费率最低0.30")
    private BigDecimal weiXinJiejikaD0;      //微信借记卡D0费率
    private Integer    weiXinJiejikaD0Fj;    //微信借记卡D0附加

    /** 支付宝 借记卡 **/
    @DecimalMin(value = "0.30",message = "支付宝借记卡D0费率最低0.30")
    private BigDecimal zhifuBaoJiejikaD0;      //支付宝借记卡D0费率
    private Integer    zhifuBaoJiejikaD0Fj;    //支付宝借记卡D0附加


    /**
     * 数据库费率转换为页面显示
     * @param merchantModelDetails
     * @return
     */
    public MerchantModelDetailVo dbFormatModelDetailsView(List<MerchantModelDetail> merchantModelDetails){
        MerchantModelDetailVo mv = new MerchantModelDetailVo();
        for (MerchantModelDetail modelDetail : merchantModelDetails) {
            BigDecimal fl = new BigDecimal(modelDetail.getDearFl()); //费率
            Integer   fj = modelDetail.getArmarkFj(); //附加
            Integer   fd = Integer.parseInt(modelDetail.getDearFd()); //封顶
            //银行卡
            if (modelDetail.getRateType() == 0
                    && modelDetail.getCardType() == 2
                    && modelDetail.getSettleType() == 0) {  // 贷记卡 D0
                mv.setYinhangkaDaijikaD0(fl);
                mv.setYinhangkaDaijikaD0Fj(fj);
            } else if (modelDetail.getRateType() == 0
                    && modelDetail.getCardType() == 1
                    && modelDetail.getSettleType() == 0){   // 借记卡 D0
                mv.setYinhangkaJiejikaD0(fl);
                mv.setYinhangkaJiejikaD0Fj(fj);
                mv.setYinhangkaJiejikaD0Fd(fd);
            }  else if (modelDetail.getRateType() == 1          //云闪付
                        && modelDetail.getCardType() == 2
                        && modelDetail.getSettleType() == 0) {  // 贷记卡 D0
                mv.setYunshanFuDaijikaD0(fl);
                mv.setYunshanFuDaijikaD0Fj(fj);
            }  else if (modelDetail.getRateType() == 1
                    && modelDetail.getCardType() == 1
                    && modelDetail.getSettleType() == 0){   // 借记卡 D0
                mv.setYunshanFuJiejikaD0(fl);
                mv.setYunshanFuJiejikaD0Fj(fj);
            }  else if (modelDetail.getRateType() == 4          //银联二维码
                    && modelDetail.getCardType() == 2
                    && modelDetail.getSettleType() == 0) {  // 贷记卡 D0
                 mv.setQrDaijikaD0(fl);
                 mv.setQrDaijikaD0Fj(fj);
            }  else if (modelDetail.getRateType() == 4
                    && modelDetail.getCardType() == 1
                    && modelDetail.getSettleType() == 0){   // 借记卡 D0
                mv.setQrJiejikaD0(fl);
                mv.setQrJiejikaD0Fj(fj);
                mv.setQrJiejikaD0Fd(fd);
            }  else if (modelDetail.getRateType() == 3
                     && modelDetail.getCardType() == 1
                     && modelDetail.getSettleType() == 0){   // 支付宝 借记卡 D0
                mv.setZhifuBaoJiejikaD0(fl);
                mv.setZhifuBaoJiejikaD0Fj(fj);
            }  else if (modelDetail.getRateType() == 2
                    && modelDetail.getCardType() == 1
                    && modelDetail.getSettleType() == 0){   // 微信 借记卡 D0
                mv.setWeiXinJiejikaD0(fl);
                mv.setWeiXinJiejikaD0Fj(fj);
            }
        }
        return mv;
    }







}
